const ProjectRequest = require("../project/project_request.js");
const Url = require("../utils/url.js");

/**
 * 预支付接口
 */
function preparePay(orderId, ticketId, data, callback) {
  const URL = Url.newInstance("/pay/order/" + orderId + "/prepare");
  if (null !== ticketId && undefined !== ticketId){
    URL.setPara('ticketId', ticketId)
  }
  ProjectRequest.postRequest(URL.get(), data, callback);
}

/**
 * 线下支付
 */
function payUnderLine(orderId, ticketId, data, callback) {
  const URL = Url.newInstance("/pay/order/" + orderId + "/underLine");
  if (null !== ticketId && undefined !== ticketId) {
    URL.setPara('ticketId', ticketId)
  }
  ProjectRequest.postRequest(URL.get(), data, callback);
}

/**
 * 普通用户登录充值-支付接口
 */
function generalUserRecharge(data, callback) {
  const url = "/pay/recharge/user/general";
  ProjectRequest.postRequest(url, data, callback);
}

/**
 * 获取首充最小金额
 */
function gainGeneralUserRechargeMinAmount(callback){
  const url = "/pay/recharge/user/general/gain/first/amount";
  ProjectRequest.getRequest(url, callback);
}

/**
 * exports
 */
module.exports = {
  preparePay: preparePay,
  payUnderLine: payUnderLine,
  generalUserRecharge: generalUserRecharge,
  gainGeneralUserRechargeMinAmount: gainGeneralUserRechargeMinAmount
};